package com.cqw.enums;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.sun.org.apache.bcel.internal.generic.NEW;
import org.springframework.data.domain.Sort;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

public class EnumTest {

    public static void main(String[] args) throws IOException {

//        String str = "3";
//
//        switch (str) {
//            case "1":
//            case "2":
//                System.out.println("已支付");
//            case "3":
//                System.out.println("待付款");
//            default:
//                System.out.println("weizhi");


//        Date dayByDays = getDayByDays(new Date(), -1);
//        String date = getDate(new Date(), "yyyy-MM-dd");
//        System.out.println(date);


        String level = getLevel(10);
        //System.out.println(level);
//        List<String> properties = Arrays.asList(level);
//        Iterator var3 = properties.iterator();
//
//
//        while (var3.hasNext()) {
//            String property = (String) var3.next();
//            System.out.println(property);
//        }
//
//        String str = "";
//        List list = str == null ? new ArrayList<>() : Arrays.asList(str);
//        for (Object o : list) {
//            System.out.println("===" + o);
//        }

//
//        String name = "曹问题而特润特瑞";
//        String nickName = "";
//        int count = 0;
//        System.out.println(name.getBytes().length);
//        if (name.getBytes().length>=4){
//            for (int i = 0; i < name.length(); i++) {
//                nickName = nickName + name.charAt(i);
//                count = nickName.getBytes().length;
//                if (count >= 4){
//                    break;
//                }
//            }
//        }
//        nickName = nickName + "***";
//        System.out.println(nickName);
//
//
////        System.out.println(name.charAt(0));
////        byte[] bytes = name.getBytes(StandardCharsets.UTF_8);
////        System.out.println(bytes.length);
//
//        List<String> list = Arrays.asList("1", "2", "3");
//
//        boolean isNotPass =
//                list.stream().anyMatch(str -> "6".equals(str)  && false);
//
//
//        Date dayByMonths = getDayByMonths(new Date(), 3);
//        String date = getDate(dayByMonths, "yyyy-MM-dd HH:mm:ss");
//        System.out.println(date);
//
//        if (new Date().before(dayByMonths)) {
//            System.out.println(1);
//        }

//
//        BigDecimal bigDecimal = new BigDecimal("0");
//        for (int i = 0; i < 3; i++) {
//            bigDecimal = bigDecimal.add(new BigDecimal(i));
//        }
//
//        System.out.println(bigDecimal);

//
//        StringBuilder sbf = new StringBuilder();
//        Map<String, String> map = new LinkedHashMap<>();
//        map.put("to", "1111");
//        map.put("content", "werwerwer");
//        map.put("from", "3423423");
//        sbf.append("#定制内容：");
//
//
//        sbf.append(JSON.toJSONString(map));
//        sbf.append("#");
//        System.out.println(
//                sbf.toString()
//        );
//
//
//        Card card = new Card();
//        card.setTo("1111");
//        card.setContent("werwerwer");
//        card.setFrom("3423423");
//        System.out.println(JSON.toJSONString(card));

        //
//        URL url = new URL("http://dmcs-cg.oss-cn-shanghai.aliyuncs.com/ysl/0715/activity-process_03.png");
////        FileInputStream fileInputStream = new FileInputStream(String.valueOf(url));
//        InputStream inputStream = url.openStream();

        List<String> list = null;
        for (String s : list) {

        }

    }


    public static Date getDayByDays(Date date, Integer days) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        cal.set(Calendar.DAY_OF_MONTH, cal.get(Calendar.DAY_OF_MONTH) + days);
        return cal.getTime();
    }

    public static Date getDayByMonths(Date date, Integer months) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        cal.add(Calendar.MONTH, months);
        return cal.getTime();
    }

    public static String getDate(Date date, String formatString) {

        SimpleDateFormat format = new SimpleDateFormat(formatString);

        return format.format(date);

    }


    public static String getLevel(int queryDTO) {
        List<String> levelList = Arrays.asList("3,10,30,50".split(","));
        String result = "";
        for (int i = 0; i < levelList.size(); i++) {
            if (Integer.valueOf(levelList.get(i)) == queryDTO) {
                switch (i + 1) {
                    case 1:
                        result = "firstCompleteTime";
                        break;
                    case 2:
                        result = "secondCompleteTime";
                        break;
                    case 3:
                        result = "thirdCompleteTime";
                        break;
                    case 4:
                        result = "fouthCompleteTime";
                        break;
                }
                break;
            }
        }
        return result;
    }


}

